﻿<%@ Page Title="Currency rates" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ManageCurrency.aspx.cs" Inherits="AdminSite.manageCurrency" %>


<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <section class="featured">
        <asp:UpdatePanel runat="server">
            <ContentTemplate>
                <label>Select company</label>
                <asp:DropDownList runat="server" ID="ddlCompanies" AutoPostBack="True"
                    ItemType="AdminSite.Models.Company"
                    SelectMethod="GetCompanies"
                    DataTextField="CompanyName"
                    DataValueField="CompanyId"
                    OnSelectedIndexChanged="BindDataToCurrencyGrid">
                </asp:DropDownList>
                <hr />
                <asp:GridView runat="server" ID="gvCurrency"
                    AutoGenerateColumns="False"
                    DataKeyNames="CurrencyId"
                    OnSelectedIndexChanged="EditCurrent">
                    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                    <AlternatingRowStyle BackColor="White" />
                    <SelectedRowStyle Font-Bold="True"></SelectedRowStyle>
                    <Columns>
                        <asp:ButtonField DataTextField="CurrencyName" CommandName="Select" HeaderText="Currency">
                            <ItemStyle Width="100"></ItemStyle>
                        </asp:ButtonField>
                        <asp:BoundField DataField="BankBuy" HeaderText="Buy" DataFormatString="{0:c}">
                            <ItemStyle Width="80"></ItemStyle>
                        </asp:BoundField>
                        <asp:BoundField DataField="BankSell" HeaderText="Sell" DataFormatString="{0:c}">
                            <ItemStyle Width="80"></ItemStyle>
                        </asp:BoundField>

                    </Columns>
                </asp:GridView>
                <hr />
                <asp:Panel runat="server" ID="pnlCurrencyDetails" Visible="false">

                    <table runat="server" class="label">
                        <tr>
                            <td colspan="2">Set new values for selected currency</td>
                        </tr>
                        <tr>
                            <td>Buy</td>
                            <td>
                                <asp:TextBox runat="server" ID="BuyValue" Width="70"></asp:TextBox>
                                <asp:CustomValidator runat="server" ID="BuyValueValidation"
                                    ControlToValidate="BuyValue"
                                    ErrorMessage="Correct value, please"
                                    OnServerValidate="ValidateCurrencyBuyValues">
                                </asp:CustomValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>Sell</td>
                            <td>
                                <asp:TextBox runat="server" ID="SellValue" Width="70"></asp:TextBox>
                                <asp:CustomValidator runat="server" ID="SellValueValidation"
                                    ControlToValidate="SellValue"
                                    ErrorMessage="Correct value, please"
                                    OnServerValidate="ValidateCurrencySellValues">
                        
                                </asp:CustomValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:LinkButton runat="server" ID="btnApplyChanges" Text="Apply" OnCommand="UpdateCurrency"></asp:LinkButton></td>
                            <td>
                                <asp:LinkButton runat="server" ID="btnCancelChanges" Text="Cancel" CausesValidation="False" OnCommand="CancelUpdating"></asp:LinkButton></td>
                        </tr>
                    </table>
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    </section>
</asp:Content>
